#include "stdafx.h"
#include "UIWindowBase.h"
#include "UIWindow.h"
//#include "UIRect.h"

CUIWindowBase::CUIWindowBase( HWND hWnd ): m_hWnd( hWnd ), m_bSkined( FALSE ), m_OldWndProc( NULL )
{

}

CUIWindowBase::~CUIWindowBase()
{

}

HWND CUIWindowBase::GetHwnd()
{
    return m_hWnd;
}

// void CUIWindowBase::GetWindowRect(CUIRect* pRect)
// {
// 	RECT rcWnd;
// 	::GetWindowRect(m_hWnd,&rcWnd);
// 	pRect->SetPosition(rcWnd.left,rcWnd.top);
// 	pRect->SetSize(rcWnd.right-rcWnd.left,rcWnd.bottom-rcWnd.top);
// }
//
// void CUIWindowBase::GetClientRect(CUIRect* pRect)
// {
// 	RECT rcClient;
// 	::GetClientRect(m_hWnd,&rcClient);
// 	pRect->SetPosition(rcClient.left,rcClient.top);
// 	pRect->SetSize(rcClient.right-rcClient.left,rcClient.bottom-rcClient.top);
// }

DWORD CUIWindowBase::GetStyle()
{
    return ( DWORD )::GetWindowLong( m_hWnd, GWL_STYLE );
}

DWORD CUIWindowBase::GetExStyle()
{
    return ( DWORD )::GetWindowLong( m_hWnd, GWL_EXSTYLE );
}

BOOL CUIWindowBase::IsSkined()
{
    return ( TRUE == m_bSkined );
}

BOOL CUIWindowBase::IsChild()
{
    return ::IsChild( ::GetParent( m_hWnd ), m_hWnd );
}

void CUIWindowBase::SaveOldWindowProc( WNDPROC NewWndProc )
{
    m_OldWndProc = NewWndProc;
}

WNDPROC CUIWindowBase::GetOldWindowProc()
{
    return m_OldWndProc;
}

LRESULT CUIWindowBase::ProcessUIMsg( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    return DefaultWindowProc( uMsg, wParam, lParam );
}

LRESULT CUIWindowBase::DefaultWindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam )
{
    if ( NULL != m_OldWndProc )
    {
        return ::CallWindowProc( m_OldWndProc, m_hWnd, uMsg, wParam, lParam );
    }
    else
        return ::DefWindowProc( m_hWnd, uMsg, wParam, lParam );
}
